package yang.VirtualMachine.chapter9.classStruct.constantPool;

import java.io.IOException;
import java.io.InputStream;

import yang.VirtualMachine.chapter9.ClassBean;
import yang.VirtualMachine.chapter9.ClassUtil;

/**
 * u1 tag;u2 class_index;	u2 name_and_type_index
 * @author xinxin
 */
public class Con_MethodrefProcesser implements PoolValue {
	
	public static int tag = ConstantPoolController.CONSTANT_Fieldref;
	
	private int classIndex;
	
	private int nameAndTypeIndex;

	@Override
	public void process(InputStream input) throws IOException {
		classIndex = (int) ClassUtil.getNumByStream(input, 2);
		nameAndTypeIndex = (int) ClassUtil.getNumByStream(input, 2);
	}

	@Override
	public String getValue() {
		PoolValue classValue = ClassBean.getInstance().constantPool[classIndex];
		PoolValue nameAndTypeValue = ClassBean.getInstance().constantPool[nameAndTypeIndex];
		return classValue.getValue() + ":" + nameAndTypeValue.getValue();
	}

}
